import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache
import heapq
from locale import resetlocale
from pickle import FALSE
import random
import math
from collections import Counter
import sys
mod = 10**9+7
def inp():
return(int(sys.stdin.readline()))
def inlt():
return(list(map(int,sys.stdin.readline().split())))
def insr():
s = sys.stdin.readline()[:-1]
return(s)
def invr():
return(map(int,input().split()))
def gcd(a,b):
if b == 0:
return a
return gcd(b, a % b)
class UF:
def __init__(self, size):
self.parent = list(range(size))
self.rank = [0] * size
def find(self, x):
if self.parent[x] == x:
return x
return self.find(self.parent[x])
def union(self, x, y):
px = self.find(x)
py = self.find(y)
if px == py:
return
if self.rank[px] > self.rank[py]:
self.parent[py] = px
elif self.rank[px] < self.rank[py]:
self.parent[px] = py
else:
self.parent[px] = py
self.rank[py] += 1
class BIT:
def __init__(self, n):
self.sums = [0] * (n+1)
def update(self, i, delta):
while i < len(self.sums):
self.sums[i] += delta
i += i & (-i)
def query(self, i):
res = 0
while i > 0:
res += self.sums[i]
i -= i & (-i)
return res
class NumArray:
def __init__(self, nums):
self.bit = BIT(len(nums))
for i, num in enumerate(nums):
self.bit.update(i+1, num)
self.nums = [0] + nums
def update(self, i, val):
self.bit.update(i+1, val - self.nums[i+1])
self.nums[i+1] = val
def sumRange(self, i, j):
return self.bit.query(j+1) - self.bit.query(i)
for v in range(1):
n = inp()
a = inlt()
m = inp()
b = inlt()
idx = 0
ok = True
left = 0
ans = []
for x in b:
val = 0
start = idx
while val < x and idx < n:
val += a[idx]
idx += 1
if val != x or (idx - start > 1 and min(a[start:idx]) == max(a[start:idx])):
ok = False
break
center = start
if start == idx:
ok = False
break
largest = max(a[start:idx])
lp = 0
rp = 0
for i in range(start, idx):
if i != start:
if a[i] == largest and a[i-1] != largest:
ans.append(str(i - left+1)+ " L")
left += 1
center = i
lp = 1
break
if i != idx - 1:
if a[i] == largest and a[i+1] != largest:
ans.append(str(i-left+1)+ " R")
center = i
rp = 1
break
for j in range(start, center - lp):
ans.append(str(center-left+1) + " L")
left += 1
for j in range(center + rp, idx-1):
ans.append(str(center - left+1) + " R")
left += idx - center - 1
if idx != n:
ok = False
if not ok:
print("NO")
break
print("YES")
for s in ans:
print(s)
Teddy and Tweety | Partitioning binary strings |
Special sets | Smallest chosen word |
Going to office | Color the boxes |
Missing numbers | Maximum sum |
13 Reasons Why | Friend's Relationship |
Health of a person | Divisibility |
A. Movement | Numbers in a matrix |
Sequences | Split houses |
Divisible | Three primes |
Coprimes | Cost of balloons |
One String No Trouble | Help Jarvis! |
Lift queries | Goki and his breakup |
Ali and Helping innocent people | Book of Potion making |
Duration | Birthday Party |
e-maze-in | Bricks Game |